import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";


type homeResult = {
  page: any;
  result: any
};


export type UserResult = {
  // success: boolean;
  // data: {
  //   /** 用户名 */
  //   username: string;
  //   /** 当前登陆用户的角色 */
  //   roles: Array<string>;
  //   /** `token` */
  //   accessToken: string;
  //   /** 用于调用刷新`accessToken`的接口时所需的`token` */
  //   refreshToken: string;
  //   /** `accessToken`的过期时间（格式'xxxx/xx/xx xx:xx:xx'） */
  //   expires: Date;
  // };
  page: any
  result: {
    id: string | number;
    token: string;
    account: string;
    name: string;

  }
};

export type RefreshTokenResult = {
  success: boolean;
  data: {
    /** `token` */
    accessToken: string;
    /** 用于调用刷新`accessToken`的接口时所需的`token` */
    refreshToken: string;
    /** `accessToken`的过期时间（格式'xxxx/xx/xx xx:xx:xx'） */
    expires: Date;
  };
};

/** 登录 */
export const getLogin = (data?: object) => {
  return http.request<UserResult>("post", baseUrlApi("/api/backend/authregister/authlogin"), { data });
  // return http.request<UserResult>("post", '/login', { data });
};

/** 刷新token */
export const refreshTokenApi = (data?: object) => {
  return http.request<RefreshTokenResult>("get", baseUrlApi("/api/backend/authregister/qx"), { data });
};





/** 分页查询个人用户信息 */
export const userselpage = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/user/selpage"), { data });
};


/** 个人信息查询 */
export const userperinfo = (userid) => {
  return http.request<homeResult>("get", baseUrlApi(`/api/backend/user/perinfo/${userid}`));
};


/** 拉黑个人用户 */
export const useruserblackw = (userid?: string | number) => {
  return http.request<homeResult>("delete", baseUrlApi(`/api/backend/user/userblackw/${userid}`));
};







/** 分页查询黑名单用户信息 */
export const userselblackpage = (data?: object) => {
  return http.request<homeResult>("post", baseUrlApi("/api/backend/user/selblackpage"), { data });
};


/** 恢复个人用户 */
export const useruseroutblackw = (userid?: string | number) => {
  return http.request<homeResult>("delete", baseUrlApi(`/api/backend/user/useroutblackw/${userid}`));
};

/** 删除个人用户 */
export const userdelinfo = (userid?: string | number) => {
  return http.request<homeResult>("delete", baseUrlApi(`/api/backend/user/delinfo/${userid}`));
};